﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using Happy.Web.Mvc;
using Happy.Cms.Controllers.Utils;
using Happy.Cms.Query.Articles;
using Happy.Cms.Application.Articles;
using Tenoner.WebSite.Models;

namespace Tenoner.WebSite.Controllers
{
    public class AboutController : HappyController
    {
        //
        // GET: /Article/

        public ActionResult Index(Guid? id)
        {
            var articles = this.GetIndexModel();
            var article = articles.FirstOrDefault(x => !id.HasValue || x.Id == id.Value);
            article = article ?? new ArticleView();

            return View(new AboutModel
            {
                Articles = articles,
                Article = article
            });
        }

        private IEnumerable<ArticleView> GetIndexModel()
        {
            return this.FindArticlesByCategoryName("关于我们");
        }
    }
}
